#!/bin/bash

if [ $# -ne 6 ];then
    echo "host port username password slow_log_file"
fi

# 目前以测试环境机器10. 用户为vipkid用户为例
pt-query-digest --user=${3} --password=${$4} \
                --review h=${1},P=${2},D=slow_query_log,t=global_query_review \
                --history h=${1},P=${2},D=slow_query_log,t=global_query_review_history \
                --no-report --limit=%0 \
                --filter='($event->{user} || "") =~ m/^vipkid/i and $event->{host} =~ m/^10./i' \
                ${5}

# pt-query-digest --user=anemometer --password=superSecurePass --review h=10.32.16.27,P=3310,D=slow_query_log,t=global_query_review --history h=10.32.16.27,P=3310,D=slow_query_log,t=global_query_review_history --no-report --limit=%0 --filter='($event->{user} || "") =~ m/^vipkid/i and $event->{host} =~ m/^10./i' /vipkid/data/mysql_3306/log/slow_query_3306.log
